<template>
	<view class="page-fade-in" :style="{opacity: pageOpc}">
		<template v-if="pageOpc">
			<view class="content">
				<view class="note-box">
					<view class="note-item flexWrapNo" v-for="(item,index) in dataList" :key="index" @tap="goPage('/pages/operate/operateDetails?id='+item.id)">
						<view class="note-img">
							<image :src="item.t_image" mode="aspectFit"></image>
						</view>
						<view class="note-info">
							<view class="note-type">{{item.title}}</view>
							<view class="note-title">
								{{item.content}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageOpc:0,
				dataList:[]
			};
		},
		onReady(){
			setTimeout(() => {
				this.pageOpc=1
			}, 100)
		},
		onShow() {
			this.getData();
		},
		// 下拉刷新
		onPullDownRefresh: function() {
			this.freshList();
			this.$tools.loadIng()
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 500)
		},
		methods:{
			// 刷新列表
			freshList() {
				this.dataList = []
				this.getData();
			},
			// 店铺详情
			getData(){
				this.$request.post(this.$api.operateList, {}, {
					token:true
				}).then(res => {
					console.log(res)
					if (res.code==1) {
						let {
							data = {}
						} = res;
						let newArray =data.list
						this.dataList=newArray
						if(!data.consultation_status){
							uni.setTabBarBadge({
								index:2,
								text:'!'
							})
						}else{
							uni.removeTabBarBadge({
								index:data
							})
						}
					}
				}).finally(() => {
					setTimeout(()=>{
						this.$tools.hideLoading()
					}, 1000)
				})
			},
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 28upx;
	}
	.note-box{
		.note-item{
			margin-bottom: 32rpx;
			align-items: flex-start;
			.note-img{
				width: 240rpx;
				height: 156rpx;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				overflow: hidden;
				flex: none;
				margin-right: 24rpx;
			}
			.note-info{
				.note-type{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFB726;
					line-height: 40rpx;
					@include ellipsis(1);
				}
				.note-title{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 40rpx;
					margin-top: 14rpx;
					@include ellipsis(2);
				}
			}
		}
	}
</style>
